<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<?php $this->load->view('head'); ?>
</head>

<body>
	<?php $this->load->view('header_admin.php'); ?>
	
	<!-- Content Area -->
	<div class="wrapper-world content">
		<h1><?php $search = $this->input->post('search'); echo ((!empty($search)) ? $search : 'Users'); ?> <span class="quantity"><?php echo count($users); ?></span> <span class="quantity link"><?php echo anchor('/users/new', '+ New'); ?></span> <span class="quantity link"><?php echo anchor('/companies', 'View Companies'); ?></span></h1>
		<div class="wrapper">
			<?php echo form_open('/users', 'class="standard-form" id="searchform"'); ?>
				<div class="type-text"><input type="text" name="search" /></div>
				<div class="search-listbox" >
				<select name="searchbox" id="searchbox" onchange="document.getElementById('searchform').submit();">
				  <option value="ID" selected="selected">Search by ID</option>
				  <option value="Name">Search by Name</option>
				  <option value="Phone">Search by Phone</option>
				  <option value="Address">Search by Address</option>
				</select>
				<script type="text/javascript">
				  document.getElementById('searchbox').value = "<?php echo $_POST['searchbox'];?>";
				</script>
				</div>
				<div class="clr"></div>
			</form>
		</div>
		<div class="job-listing">
			<div class="wrapper-world"> <!-- zaglaviq -->
				<div class="wrapper">
					<div class="job-id">User ID</div>
					<div class="job-details">Name and Company</div>
					<div class="job-status">Oncoming Jobs</div>
					<div class="job-price">Due</div>
					<div class="job-action">Action</div>
					<div class="clr"></div>
				</div>
			</div>
			
			<?php $c = 0; foreach ($users as $uinfo): ?>
			<div class="wrapper-world job-<?php echo (($c%2 == 0) ? "odd" : "even"); ?>">
				<div class="wrapper">
					<div class="job-id"><?php echo anchor('/users/edit/'.$uinfo->uid, $uinfo->user_id); ?></div>
					<div class="job-details"><?php echo anchor('/users/edit/'.$uinfo->uid, $uinfo->name); ?><?php if ($uinfo->company->id > 0): ?> from <?php echo anchor('/companies/view/'.$uinfo->company->id, $uinfo->company->name); ?><?php endif; ?></div>
					<div class="job-status"><?php echo $this->Jobs->getOncoming($uinfo->uid, true); ?></div>
					<div class="job-price"><?php echo $this->Jobs->formatPrice($this->Jobs->getDuePrice($uinfo->uid) + $this->Jobs->getOverduePrice($uinfo->uid))?></div>
					<div class="job-action"><?php echo anchor_img('/umanager/loginasuser/'.$uinfo->uid, 'title="On behalf of '. $uinfo->name .'"', 'assets/images/icons/represent.png'); ?><!-- <?php echo anchor_img('/addjoborder/'.$uinfo->uid, 'title="Add job order"', 'assets/images/icons/represent.png'); ?>--> <?php if ($user->level == 3) { echo anchor_img('/deleteuser/'.$uinfo->uid, 'title="Delete user"', 'assets/images/icons/delete.png') ." "; } ?><?php echo anchor_img('/viewuser/'.$uinfo->uid, 'title="View details"', 'assets/images/icons/view.png'); ?><?php if($uinfo->Block == 0){echo anchor_img('/block/'.$uinfo->uid, 'title="Block user"', 'assets/images/icons/lock.png'); } else {echo anchor_img('/unblock/'.$uinfo->uid, 'title="Unblock user"', 'assets/images/icons/unlock.png');}?></div>
					<div class="clr"></div>
				</div>
			</div>
			<?php $c++; endforeach; ?>
		</div>
		
		<!--          -----------------------------------------------------------------------------          -->
		
	</div> <!-- end of wrapper-world and .content -->
	
	
		
	<div class="wrapper-world footer-top">
		<div class="wrapper"></div>	
	</div>
	
	<?php $this->load->view('footer'); ?>
</body>
</html>
